import { useRoutes, useLocation, useNavigate } from "react-router-dom";
import router from "../router";
import { useEffect } from "react";
function RouterView() {
   let { pathname } = useLocation()
   let navgate = useNavigate()
   let outlet = useRoutes(router)
   document.title = outlet.props.match.route.meta.title
   let token = localStorage.getItem("token")
   
   useEffect(() => {
      if (!token && pathname != "/login") {

         navgate("/login")
      }
   }, [])
   return outlet
}
export default RouterView
